package cn.dzhang.rcp.hyperbola.actions;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import org.eclipse.jface.action.Action;
import org.eclipse.ui.IViewReference;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchWindow;

import cn.dzhang.rcp.hyperbola.common.UIConstants;

public class ShowViewAction extends Action {

	public static final String ID = "cn.dzhang.rcp.hyperbola.actions.ShowViewAction";

	private final IWorkbenchWindow window;

	public ShowViewAction(IWorkbenchWindow window) {
		super();
		this.window = window;

		setId(ID);
		setText("Show View");
		setToolTipText("show all views");
		setImageDescriptor(UIConstants.ImageDescriptors.COMMENT_16);
	}

	@Override
	public void run() {
		List<IViewReference> views = new ArrayList<IViewReference>();
		IWorkbenchPage[] pages = window.getPages();

		for (IWorkbenchPage page : pages) {
			Collections.addAll(views, page.getViewReferences());
		}

		for (IViewReference view : views) {
			System.err.println(view.getTitle());
		}
	}
}
